package com.example.mymavendemo.common.lang;

import lombok.Data;

import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    private int code;
    private String msg;
    private T data;

    public static<T> Result<T> success(T data) {

        return success(200,"操作成功",data);
    }
    public static<T> Result<T> success(int code, String msg, T data) {
        Result<T> r = new Result<T>();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }

    public static<T> Result<T> fail(String msg){
        return fail(400,msg,null);
    }

    public static<T> Result<T> fail(int code, String msg, T data) {
        Result<T> r = new Result<T>();
        r.setCode(code);
        r.setMsg(msg);
        r.setData(data);
        return r;
    }


}
